/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.agi.util.sound;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;

/**
 *
 * @author Renato
 */
public class OutputMixer {
    private AudioFormat audioFormat;  
    private SourceDataLine source;
    private byte[] buf;
    public OutputMixer(MicrofoneMixer inputMixer) throws LineUnavailableException{        
        audioFormat=inputMixer.getAudioFormat();
        buf=inputMixer.getBuf();
        BuscadorDeFalantes buscador=new BuscadorDeFalantes(audioFormat);
        source=buscador.getLine();        
    }
    
    public void play() throws LineUnavailableException{
        source.open();
        source.start();
        source.write(buf, 0, (int)audioFormat.getFrameRate());
        source.stop();        
    }    
}
